import request from '../utils/request';

// 财务管理相关API
export const financeApi = {
  // 获取财务概览
  getFinanceOverview: () => {
    return request.get('/api/finance/overview');
  },

  // 获取收入统计
  getIncomeStatistics: (params) => {
    return request.get('/api/finance/income', { params });
  },

  // 获取支出统计
  getExpenseStatistics: (params) => {
    return request.get('/api/finance/expense', { params });
  },

  // 获取现金流
  getCashFlow: (params) => {
    return request.get('/api/finance/cashflow', { params });
  },

  // 获取财务报表
  getFinancialReports: (params) => {
    return request.get('/api/finance/reports', { params });
  },

  // 生成财务报表
  generateFinancialReport: (params) => {
    return request.post('/api/finance/reports/generate', params);
  },

  // 下载财务报表
  downloadFinancialReport: (reportId) => {
    return request.get(`/api/finance/reports/${reportId}/download`, {
      responseType: 'blob'
    });
  },

  // 获取预算信息
  getBudgetInfo: (params) => {
    return request.get('/api/finance/budget', { params });
  },

  // 创建预算
  createBudget: (data) => {
    return request.post('/api/finance/budget', data);
  },

  // 更新预算
  updateBudget: (id, data) => {
    return request.put(`/api/finance/budget/${id}`, data);
  },

  // 删除预算
  deleteBudget: (id) => {
    return request.delete(`/api/finance/budget/${id}`);
  },

  // 获取预算执行情况
  getBudgetExecution: (budgetId) => {
    return request.get(`/api/finance/budget/${budgetId}/execution`);
  }
};
